<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html class="no-js fixed-layout">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/Public/vendor/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/Public/vendor/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/admin.css">
    
    <link rel="stylesheet" href="/Public/assets/admin/css/common.css">

</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
    以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong>Amaze UI</strong> <small>后台管理模板</small>
    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span class="am-badge am-badge-warning">5</span></a></li>
            <li class="am-dropdown" data-am-dropdown>
                <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                    <span class="am-icon-users"></span>欢迎<?php echo ($_SESSION[user]['username']); ?> 管理员 <span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
                    <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                    <li><a href="<?php echo U('User/logout');?>"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
        </ul>
    </div>
</header>

    <div class="am-cf admin-main">
        <!-- sidebar start -->
        <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
        <ul class="am-list admin-sidebar-list">
            <li><a href="<?php echo U('Index/index');?>"><span class="am-icon-home"></span> 首页</a></li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-shopping-cart"></span> 商城中心 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
                    <li><a href="<?php echo U('Product/index');?>" class="am-cf"><span class="am-icon-product-hunt"></span> 商品管理<span class="am-badge am-badge-secondary am-margin-right am-fr">33</span></a></li>
                    <li><a href="<?php echo U('Category/index');?>"><span class="am-icon-puzzle-piece"></span> 分类管理</a></li>
                    <li><a href="scription:;"><span class="am-icon-th"></span> 相册页面<span class="am-badge am-badge-secondary am-margin-right am-fr">24</span></a></li>
                    <li><a href="<?php echo U('Advert/index');?>"><span class="am-icon-calendar"></span> 广告管理</a></li>
                    <li><a href="<?php echo U('Customer/index');?>"><span class="am-icon-user"></span> 会员管理</a></li>
                    <li><a href="<?php echo U('Order/index');?>"><span class="am-icon-first-order"></span> 订单管理</a></li>
                    <li><a href="<?php echo U('Product/recycle');?>"><span class="am-badge am-badge-danger am-margin-right am-fr">22</span> 商品回收站</a></li>
                </ul>
            </li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-abc'}"><span class="am-icon-shopping-cart"></span> 系统管理 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-abc">
                    <li><a href="<?php echo U('AuthSet/rule_manage');?>" class="am-cf"><span class="am-icon-product-hunt"></span> 菜单与权限<span class="am-badge am-badge-secondary am-margin-right am-fr">33</span></a></li>
                    <li><a href="<?php echo U('AuthSet/group_manage');?>"><span class="am-icon-puzzle-piece"></span> 用户组管理</a></li>
                    <li><a href="<?php echo U('AuthSet/user_manage');?>"><span class="am-icon-calendar"></span> 用户管理</a></li>
                </ul>
            </li>
            <li><a href="admin-table.html"><span class="am-icon-table"></span> 表格</a></li>
            <li><a href="admin-form.html"><span class="am-icon-pencil-square-o"></span> 表单</a></li>
            <li><a href="#"><span class="am-icon-sign-out"></span> 注销</a></li>
        </ul>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-bookmark"></span> 公告</p>
                <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
            </div>
        </div>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-tag"></span> wiki</p>
                <p>Welcome to the Amaze UI wiki!</p>
            </div>
        </div>
    </div>
</div>


            <!-- sidebar end -->

            <!-- content start -->
            
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑用户组</strong> /
                <small>Edit Group</small>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="am-tab-panel">
                    <form class="am-form"  action="/Admin/AuthSet/edit_group/id/2.html" method="post" >
                        <input type="hidden" name="id" value="<?php echo ($group["id"]); ?>">
                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                用户组名
                            </div>
                            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                                <input type="text" class="am-input-sm" id="title" name="title"
                                       value="<?php echo ($group["title"]); ?>">
                            </div>
                        </div>

                        <div class="am-g am-margin-top">
                            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                权限列表
                            </div>
                            <div class="am-u-sm-8 am-u-md-8 am-u-end col-end">

                                <?php if(is_array($rules)): $i = 0; $__LIST__ = $rules;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$rule): $mod = ($i % 2 );++$i;?><div class="am-panel am-panel-default">

                                        <div class="am-panel-hd">
                                            <label class="am-checkbox-inline">
                                                <input type="checkbox" value="<?php echo ($rule["id"]); ?>"
                                                       name="rule_id[]" class="permission1"
                                                <?php if(in_array($rule['id'],explode(',',$group['rules']) )): ?>checked<?php endif; ?>
                                                >
                                                <span class="am-badge am-badge-secondary am-text-sm am-radius">
                                                    <?php echo ($rule["title"]); ?>
                                                </span>
                                            </label>
                                        </div>
                                        <div class="am-panel-bd">
                                            <?php if(is_array($rule["children"])): $i = 0; $__LIST__ = $rule["children"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$children): $mod = ($i % 2 );++$i;?><div class="am-g am-margin-top">
                                                    <div class="am-u-sm-4 am-u-md-3 am-text-right p2">
                                                        <label class="am-checkbox-inline">
                                                            <input type="checkbox" value="<?php echo ($children["id"]); ?>"
                                                                   name="rule_id[]" class="permission2"
                                                            <?php if(in_array($children['id'],explode(',',$group['rules']) )): ?>checked<?php endif; ?>
                                                            >
                                                            <span class="am-badge am-badge-success am-radius">
                                                                <?php echo ($children["title"]); ?>
                                                            </span>
                                                        </label>
                                                    </div>
                                                    <div class="am-u-sm-8 am-u-md-9 am-u-end col-end p3">
                                                        <?php if(is_array($children["child"])): $i = 0; $__LIST__ = $children["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$child): $mod = ($i % 2 );++$i;?><label class="am-checkbox-inline">
                                                                <input class="rule_three" type="checkbox" value="<?php echo ($child["id"]); ?>"
                                                                       name="rule_id[]"
                                                                <?php if(in_array($child['id'],explode(',',$group['rules']) )): ?>checked<?php endif; ?>
                                                                >
                                                                <?php echo ($child["title"]); ?>
                                                            </label><?php endforeach; endif; else: echo "" ;endif; ?>
                                                    </div>

                                                </div><?php endforeach; endif; else: echo "" ;endif; ?>
                                        </div>
                                    </div><?php endforeach; endif; else: echo "" ;endif; ?>
                            </div>
                        </div>

                        <div class="am-margin">
                            <button class="submit am-btn am-btn-primary">保 存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

            <!-- content end -->

    </div>

    <a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
       data-am-offcanvas="{target: '#admin-offcanvas'}"></a>

    <!--[if lt IE 9]>
    <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
    <script src="/Public/vendor/assets/js/amazeui.ie8polyfill.min.js"></script>
    <![endif]-->

    <!--[if (gte IE 9)|!(IE)]><!-->
    <script src="/Public/vendor/assets/js/jquery.min.js"></script>
    <!--<![endif]-->
    <script src="/Public/vendor/assets/js/amazeui.min.js"></script>
    <script src="/Public/vendor/assets/js/app.js"></script>
    
    <script src="/Public/vendor/assets/js/jquery.min.js"></script>
    <script>
        $(function () {
            //一级全选反选
            $('.permission1').click(function () {
                var checked = $(this).prop('checked');
                $(this).parents('.am-panel-hd').next().find('input').prop('checked', checked);
            });

            //二级全选反选
            $('.permission2').click(function () {
                var checked = $(this).prop('checked');
                $(this).parents('.am-text-right').next().find('input').prop('checked', checked);
                //获取所有的二级选中的长度
                var length2_checked = $(this).parents('.am-panel').find('.permission2:checked').length;

                //只要所有的二级有一个被选中，一级自动被选中
                if (length2_checked > 0) {
                    $(this).parents('.am-panel').find(".permission1").prop('checked', true);
                } else {
                    $(this).parents('.am-panel').find(".permission1").prop('checked', false);
                }
            });
            $(".rule_three").click(function () {
                // 如果有三级一个选中，自动选择二级和一级
                var length3_checked = $(this).parents('.p3').find("input:checked").length;
                if (length3_checked > 0) {
                    $(this).parents('.p3').prev().find(".permission2").prop('checked', true);
                    $(this).parents('.am-panel').find(".permission1").prop('checked', true);
                }else{
                    $(this).parents('.p3').prev().find(".permission2").prop('checked', false);
                    $(this).parents('.am-panel').find(".permission1").prop('checked', false);

                }

            })
            $('.submit').click(function () {
                var info = $("input").serialize();
//                console.log(info);
//                return false;
                $.ajax({
                    type:'post',
                    url:"<?php echo U('edit_group');?>",
                    data:info,
                    success:function (face) {
                        if(face.status==1){
                            alert(face.msg);
                            location.href = "<?php echo U('AuthSet/group_manage');?>"
                        }else{
                            alert(face.msg);
                            return false;
                        }

                    }
                })
                return false;
            })


            //            $('.submit').click(function () {
            //                var info = {
            //                    username: $('#username').val(),
            //                    email: $('#email').val(),
            //                    mobile: $('#mobile').val(),
            //                    password: $('#password').val(),
            //                    check_password: $('#check_password').val(),
            //                    group_ids: $('.checked_id:checked').serialize(),
            //                };
            //
            //                if (info.username.length < 3) {
            //                    alert('您输入的用户名不能小于3个长度！');
            //                    return false;
            //                }
            //                if (info.password.length < 6) {
            //                    alert('您输入的密码不能小于6位！')
            //                    return false;
            //                }
            //                var patter = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
            //                if (!patter.test(info.email)) {
            //                    alert('您输入的邮箱格式不正确！');
            //                    return false;
            //                }
            //                var regs = /^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$/;
            //                if (!regs.test(info.mobile)) {
            //                    alert('您输入的电话号码格式不正确！');
            //                    return false;
            //                }
            //                if (info.check_password != info.password) {
            //                    alert('两次密码输入不一致！');
            //                    return false;
            //                }
            //                if (info.group_ids = "") {
            //                    alert('您至少选择一项权限！');
            //                    return false;
            //                }
            //                $.post("/Admin/AuthSet/a", info, function (file) {
            //                    if (file.status == 1) {
            //                        alert(file.msg);
            //                        location.href = "<?php echo U('AuthSet/user_manage');?>";
            //                    } else {
            //                        alert(file.msg);
            //                        return false;
            //                    }
            //                })
            //                return false;
            //            })
        })


    </script>

</body>
</html>